package com.xiao.dao;

import com.xiao.Uitils.SqlSessionUitils;
import com.xiao.mapper.classtableMapper;
import com.xiao.mapper.user2Mapper;
import com.xiao.mapper.user3Mapper;
import com.xiao.mapper.userMapper;
import org.apache.ibatis.session.SqlSession;
import org.junit.jupiter.api.Test;

import java.util.List;

public class userTestDemo {
    @Test
    public void method(){
        SqlSessionUitils sqlSessionUitils = new SqlSessionUitils();
        SqlSession sqlSession = sqlSessionUitils.SqlSession();
        userMapper mapper = sqlSession.getMapper(userMapper.class);
        List<user> users = mapper.selectAll();
        users.forEach(System.out::println);
        sqlSession.commit();
        sqlSession.close();
    }
    @Test
    public void method2(){
        SqlSessionUitils sqlSessionUitils = new SqlSessionUitils();
        SqlSession sqlSession = sqlSessionUitils.SqlSession();
        user2Mapper mapper = sqlSession.getMapper(user2Mapper.class);
        List<user2> select = mapper.select();

        select.forEach(System.out::println);
        sqlSession.commit();
        System.out.println();

          System.out.println("helllo");
          System.out.println("hi");
        System.out.println("hello world！");
        sqlSession.close();
    }

    @Test
    public void method3(){
        SqlSessionUitils sqlSessionUitils = new SqlSessionUitils();
        SqlSession sqlSession = sqlSessionUitils.SqlSession();
        user3Mapper mapper = sqlSession.getMapper(user3Mapper.class);
        List<user3> select = mapper.select();
        select.forEach(System.out::println);
        sqlSession.commit();
        sqlSession.close();
    }
    @Test
    public void method4(){
        SqlSessionUitils sqlSessionUitils = new SqlSessionUitils();
        SqlSession sqlSession = sqlSessionUitils.SqlSession();
        user3Mapper mapper = sqlSession.getMapper(user3Mapper.class);
        List<user3> select = mapper.selectById(1);
        select.forEach(System.out::println);
        sqlSession.commit();
        sqlSession.close();
    }
    @Test
    public void method5(){
        SqlSessionUitils sqlSessionUitils = new SqlSessionUitils();
        SqlSession sqlSession = sqlSessionUitils.SqlSession();
        user3Mapper mapper = sqlSession.getMapper(user3Mapper.class);
        List<user3> user3s = mapper.selectUser3AndClassByIdOne(4);
        System.out.println(user3s);
        sqlSession.close();
    }
    @Test
    public void method6(){
        SqlSessionUitils sqlSessionUitils = new SqlSessionUitils();
        SqlSession sqlSession = sqlSessionUitils.SqlSession();
        user2Mapper mapper = sqlSession.getMapper(user2Mapper.class);
        List<classtable> select = mapper.selectByName("小黄");
        select.forEach(System.out::println);

    }
    @Test
    public void method7(){
        SqlSessionUitils sqlSessionUitils = new SqlSessionUitils();
        SqlSession sqlSession = sqlSessionUitils.SqlSession();
        classtableMapper mapper = sqlSession.getMapper(classtableMapper.class);
        classtable classtable = mapper.selectClassAndUser2ByIdOne(2);
        System.out.println(classtable);

    }
}
